home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / MATHS / RLAB / RLAB125.ZIP / !RLaB / rlib / rank < prev    next >
Text File  |  1994-09-20  |  626b  |  28 lines

  1. //-------------------------------------------------------------------//
  2. //
  3. //  Syntax:    rank ( A )
  4. //        rank ( A , tol )
  5.  
  6. //  Description:
  7.  
  8. //  Compute the rank of the matrix A. Rank returns the number of
  9. //  singular values that are larger than:
  10. //        max( size(x) ) * norm(x,"2") * eps. 
  11.  
  12. //  If the user specifies tol, the the number of singular values
  13. //  larger than tol is returned.
  14.  
  15. //-------------------------------------------------------------------//
  16.  
  17. rank = function(x, tol)
  18. {
  19.   global (eps)
  20.  
  21.   s = svd(x);
  22.   if (!exist (tol))
  23.   { 
  24.     tol = max(size(x)) * norm(x,"2") * eps;
  25.   }
  26.   return sum(s.sigma > tol);
  27. };
  28.